package com.sg.service.biz.bff.impl;

import cn.hutool.core.bean.BeanUtil;
import com.sg.common.util.CommonFunctionHelper;
import com.sg.common.util.RedisUtil;
import com.sg.dto.biz.bff.req.*;
import com.sg.dto.biz.bff.res.*;
import com.sg.service.biz.bff.PositionService;
import com.sg.common.exception.Assert;
import com.wicket.okrframework.integration.InductionRecordService;
import com.wicket.okrframework.integration.PositionService;
import com.wicket.okrframework.integration.dto.*;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class PositionServiceImpl implements PositionService {

    @Resource
    com.sg.service.biz.framework.PositionService fwBasePositionClient;
    @Resource
    com.sg.service.biz.framework.InductionRecordService fwBaseInductionRecordClient;
    @Resource
    private RedisUtil redisUtil;

    /**
     * B1-3查询职务详情(边界)[925]
     * gen by moon at 8/18/2022, 10:21:53 PM
     */
    @Trace(operationName = "B1-3查询职务详情(边界)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryPositionDetailRespDto queryPositionDetail(BffQueryPositionDetailReqDto reqDto) {


        QueryPositionDetailBorderRespDto queryPositionDetailBorderRespDto_1 = null;
//步骤0: D1-3查询职务详情(边界) - queryPositionDetailBorder
        QueryPositionDetailBorderRespDto queryPositionDetailBorderRespDto = null;
        QueryPositionDetailBorderReqDto queryPositionDetailBorderReqDto = new QueryPositionDetailBorderReqDto();
        queryPositionDetailBorderReqDto.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:201685_1
        if (reqDto != null) {
            queryPositionDetailBorderReqDto.setPositionId(reqDto.getPositionId());//sourceId:201684_1
        }

        /*D1-3查询职务详情(边界)[3940]   */
        Assert.isNull(queryPositionDetailBorderReqDto.getPositionId(), "B1-3查询职务详情(边界)-D1-3查询职务详情(边界)-职务ID不能为空", false);
        Assert.isNull(queryPositionDetailBorderReqDto.getSubjectLifeCycle(), "B1-3查询职务详情(边界)-D1-3查询职务详情(边界)-主体生命周期不能为空", false);
        queryPositionDetailBorderRespDto = fwBasePositionClient.queryPositionDetailBorder(queryPositionDetailBorderReqDto).getData();

        queryPositionDetailBorderRespDto_1 = queryPositionDetailBorderRespDto;

        BffQueryPositionDetailRespDto retData = new BffQueryPositionDetailRespDto();
        if (queryPositionDetailBorderRespDto_1 != null) {
            retData.setPositionId(queryPositionDetailBorderRespDto_1.getPositionId());//sourceId:201694_1
            retData.setPositionNumber(queryPositionDetailBorderRespDto_1.getPositionNumber());//sourceId:201695_1
            retData.setPositionIdName(queryPositionDetailBorderRespDto_1.getPositionIdName());//sourceId:201696_1
            retData.setPositionType(queryPositionDetailBorderRespDto_1.getPositionType());//sourceId:201697_1
            retData.setPositionDutyDesc(queryPositionDetailBorderRespDto_1.getPositionDutyDesc());//sourceId:201698_1
            retData.setPositionTargetDesc(queryPositionDetailBorderRespDto_1.getPositionTargetDesc());//sourceId:201699_1
        }


        return retData;
    }

    /**
     * B1-3编制去重职务列表（边界）[1765]
     * gen by moon at 8/10/2022, 3:37:29 AM
     */
    @Trace(operationName = "B1-3编制去重职务列表（边界）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryNoRepPositionListRespDto queryNoRepPositionList(BffQueryNoRepPositionListReqDto reqDto) {


        QueryNoRepPositionListRespDto queryNoRepPositionListRespDto_1 = null;
//步骤0: D1-3查询编制去重职务列表（边界） - queryNoRepPositionList
        QueryNoRepPositionListRespDto queryNoRepPositionListRespDto = null;
        QueryNoRepPositionListReqDto queryNoRepPositionListReqDto = new QueryNoRepPositionListReqDto();
        if (reqDto != null) {
            queryNoRepPositionListReqDto.setDeptId(reqDto.getDeptId());//sourceId:53540_1
        }

        /*D1-3查询编制去重职务列表（边界）[1764]   */
        Assert.isNull(queryNoRepPositionListReqDto.getDeptId(), "B1-3编制去重职务列表（边界）-D1-3查询编制去重职务列表（边界）-部门ID不能为空", false);
        queryNoRepPositionListRespDto = fwBasePositionClient.queryNoRepPositionList(queryNoRepPositionListReqDto).getData();

        queryNoRepPositionListRespDto_1 = queryNoRepPositionListRespDto;

        BffQueryNoRepPositionListRespDto retData = new BffQueryNoRepPositionListRespDto();
        if (queryNoRepPositionListRespDto_1 != null) {
            retData.setPositionList(queryNoRepPositionListRespDto_1.getPositionList().stream().map(item -> BeanUtil.toBean(item, BffPositionDto.class)).collect(Collectors.toList()));//sourceId:63372_1
        }


        return retData;
    }

    /**
     * B1-3查询带编制统计组织职务列表（边界）[1760]
     * gen by moon at 8/10/2022, 3:37:27 AM
     */
    @Trace(operationName = "B1-3查询带编制统计组织职务列表（边界）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryOrgPositionStaffNumListRespDto queryOrgPositionStaffNumList(BffQueryOrgPositionStaffNumListReqDto reqDto) {


        QueryStaffingPositionListRespDto queryStaffingPositionListRespDto_1 = null;
//步骤0: D1-3查询编制下职务列表 - queryStaffingPositionList
        QueryStaffingPositionListRespDto queryStaffingPositionListRespDto = null;
        QueryStaffingPositionListReqDto queryStaffingPositionListReqDto = new QueryStaffingPositionListReqDto();
        if (reqDto != null) {
            queryStaffingPositionListReqDto.setStationId(reqDto.getStationId());//sourceId:53386_1
            queryStaffingPositionListReqDto.setPositionGradeId(reqDto.getPositionGradeId());//sourceId:53387_1
            queryStaffingPositionListReqDto.setOrganizationId(reqDto.getOrganizationId());//sourceId:53388_1
        }

        /*D1-3查询编制下职务列表[1730]   */
        Assert.isNull(queryStaffingPositionListReqDto.getOrganizationId(), "B1-3查询带编制统计组织职务列表（边界）-D1-3查询编制下职务列表-组织ID不能为空", false);
        queryStaffingPositionListRespDto = fwBasePositionClient.queryStaffingPositionList(queryStaffingPositionListReqDto).getData();

        queryStaffingPositionListRespDto_1 = queryStaffingPositionListRespDto;

        BffQueryOrgPositionStaffNumListRespDto retData = new BffQueryOrgPositionStaffNumListRespDto();
        if (queryStaffingPositionListRespDto_1 != null) {
            retData.setOrgPositionStaffNumList(queryStaffingPositionListRespDto_1.getOrgPositionList().stream().map(item -> BeanUtil.toBean(item, BffOrgPositionStaffNumDto.class)).collect(Collectors.toList()));//sourceId:53403_1
        }


        retData.setPageNum(queryStaffingPositionListRespDto.getPageNum());
        retData.setPageSize(queryStaffingPositionListRespDto.getPageSize());
        retData.setTotal(queryStaffingPositionListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryStaffingPositionListRespDto.getTotalNum()) / Double.valueOf(queryStaffingPositionListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B1-3查询带编制统计职务列表（边界）[1733]
     * gen by moon at 8/10/2022, 3:37:19 AM
     */
    @Trace(operationName = "B1-3查询带编制统计职务列表（边界）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryPositionStaffNumListRespDto queryPositionStaffNumList(BffQueryPositionStaffNumListReqDto reqDto) {


        QueryStaffingPositionListRespDto queryStaffingPositionListRespDto_1 = null;
//步骤0: D1-3查询编制下职务列表 - queryStaffingPositionList
        QueryStaffingPositionListRespDto queryStaffingPositionListRespDto = null;
        QueryStaffingPositionListReqDto queryStaffingPositionListReqDto = new QueryStaffingPositionListReqDto();
        if (reqDto != null) {
            queryStaffingPositionListReqDto.setStationId(reqDto.getStationId());//sourceId:53316_1
            queryStaffingPositionListReqDto.setPositionGradeId(reqDto.getPositionGradeId());//sourceId:53317_1
        }

        /*D1-3查询编制下职务列表[1730]   */

        queryStaffingPositionListRespDto = fwBasePositionClient.queryStaffingPositionList(queryStaffingPositionListReqDto).getData();

        queryStaffingPositionListRespDto_1 = queryStaffingPositionListRespDto;

        BffQueryPositionStaffNumListRespDto retData = new BffQueryPositionStaffNumListRespDto();
        if (queryStaffingPositionListRespDto_1 != null) {
            retData.setPositionStaffingStatisticsList(queryStaffingPositionListRespDto_1.getOrgPositionList().stream().map(item -> BeanUtil.toBean(item, BffPositionStaffingStatisticsDto.class)).collect(Collectors.toList()));//sourceId:53404_1
        }


        retData.setPageNum(queryStaffingPositionListRespDto.getPageNum());
        retData.setPageSize(queryStaffingPositionListRespDto.getPageSize());
        retData.setTotal(queryStaffingPositionListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryStaffingPositionListRespDto.getTotalNum()) / Double.valueOf(queryStaffingPositionListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B1-3查询职务列表（边界）[1627]
     * gen by moon at 8/10/2022, 3:36:26 AM
     */
    @Trace(operationName = "B1-3查询职务列表（边界）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryPositionListBorderRespDto queryPositionListBorder(BffQueryPositionListBorderReqDto reqDto) {


        QueryPositionListBorderRespDto queryPositionListBorderRespDto_1 = null;
//步骤0: D1-3查询职务列表（边界） - queryPositionListBorder
        QueryPositionListBorderRespDto queryPositionListBorderRespDto = null;
        QueryPositionListBorderReqDto queryPositionListBorderReqDto = new QueryPositionListBorderReqDto();
        if (reqDto != null) {
            queryPositionListBorderReqDto.setStationId(reqDto.getStationId());//sourceId:49016_1
            queryPositionListBorderReqDto.setPositionIdNameId(reqDto.getPositionIdNameId());//sourceId:51030_1
            queryPositionListBorderReqDto.setPositionGradeId(reqDto.getPositionGradeId());//sourceId:53383_1
        }

        /*D1-3查询职务列表（边界）[1653]   */

        queryPositionListBorderRespDto = fwBasePositionClient.queryPositionListBorder(queryPositionListBorderReqDto).getData();

        queryPositionListBorderRespDto_1 = queryPositionListBorderRespDto;

        BffQueryPositionListBorderRespDto retData = new BffQueryPositionListBorderRespDto();
        if (queryPositionListBorderRespDto_1 != null) {
            retData.setOrgPositionList(queryPositionListBorderRespDto_1.getOrgPositionList().stream().map(item -> BeanUtil.toBean(item, BffOrgPositionDto.class)).collect(Collectors.toList()));//sourceId:49022_1
        }


        retData.setPageNum(queryPositionListBorderRespDto.getPageNum());
        retData.setPageSize(queryPositionListBorderRespDto.getPageSize());
        retData.setTotal(queryPositionListBorderRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryPositionListBorderRespDto.getTotalNum()) / Double.valueOf(queryPositionListBorderRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B1-3查询可存档职务条件（管理）[1506]
     * gen by moon at 8/10/2022, 3:35:53 AM
     */
    @Trace(operationName = "B1-3查询可存档职务条件（管理）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryArchivePositionRespDto queryArchivePosition(BffQueryArchivePositionReqDto reqDto) {


        QueryInductionRecordListRespDto queryInductionRecordListRespDto_1 = null;
//步骤0: D1-3查就职记录列表 - queryInductionRecordList
        QueryInductionRecordListRespDto queryInductionRecordListRespDto = null;
        QueryInductionRecordListReqDto queryInductionRecordListReqDto = new QueryInductionRecordListReqDto();
        queryInductionRecordListReqDto.setSubjectLifeCycle("EDITING");//sourceId:54224_1
        queryInductionRecordListReqDto.setSpaceId(CommonFunctionHelper.getBaseInfoFromLocal().getSpecSpaceId());//CURRENT_SPACEID//sourceId:49632_1
        if (reqDto != null) {
            queryInductionRecordListReqDto.setPositionId(reqDto.getPositionId());//sourceId:40775_1
        }

        /*D1-3查就职记录列表[1505]   */
        Assert.isNull(queryInductionRecordListReqDto.getPositionId(), "B1-3查询可存档职务条件（管理）-D1-3查就职记录列表-冗余可选职务ID不能为空", false);
        Assert.isNull(queryInductionRecordListReqDto.getSubjectLifeCycle(), "B1-3查询可存档职务条件（管理）-D1-3查就职记录列表-主体生命周期不能为空", false);
        Assert.isNull(queryInductionRecordListReqDto.getSpaceId(), "B1-3查询可存档职务条件（管理）-D1-3查就职记录列表-创建于空间ID不能为空", false);
        queryInductionRecordListRespDto = fwBaseInductionRecordClient.queryInductionRecordList(queryInductionRecordListReqDto).getData();

        queryInductionRecordListRespDto_1 = queryInductionRecordListRespDto;

        BffQueryArchivePositionRespDto retData = new BffQueryArchivePositionRespDto();
        if (queryInductionRecordListRespDto_1 != null) {
            retData.setOrgInductionRecordList(queryInductionRecordListRespDto_1.getOrgInductionRecordList().stream().map(inc -> inc.getInductionRecordId()).collect(Collectors.toList()));//sourceId:40795_1
        }


        return retData;
    }

    /**
     * B1-3查询职务名称列表（边界）[1413]
     * gen by moon at 8/10/2022, 3:35:27 AM
     */
    @Trace(operationName = "B1-3查询职务名称列表（边界）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryPositionTitleListBorderRespDto queryPositionTitleListBorder(BffQueryPositionTitleListBorderReqDto reqDto) {


        QueryPositionTitleListRespDto queryPositionTitleListRespDto_1 = null;
//步骤0: D1-3查询职务名称列表 - queryPositionTitleList
        QueryPositionTitleListRespDto queryPositionTitleListRespDto = null;
        QueryPositionTitleListReqDto queryPositionTitleListReqDto = new QueryPositionTitleListReqDto();
        queryPositionTitleListReqDto.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:63339_1
        if (reqDto != null) {
            queryPositionTitleListReqDto.setPositionIdName(reqDto.getPositionIdName());//sourceId:63338_1
        }

        /*D1-3查询职务名称列表[1414]   */
        Assert.isNull(queryPositionTitleListReqDto.getSubjectLifeCycle(), "B1-3查询职务名称列表（边界）-D1-3查询职务名称列表-主体生命周期不能为空", false);
        queryPositionTitleListRespDto = fwBasePositionClient.queryPositionTitleList(queryPositionTitleListReqDto).getData();

        queryPositionTitleListRespDto_1 = queryPositionTitleListRespDto;

        BffQueryPositionTitleListBorderRespDto retData = new BffQueryPositionTitleListBorderRespDto();
        if (queryPositionTitleListRespDto_1 != null) {
            retData.setOrgPositionIdNameList(queryPositionTitleListRespDto_1.getOrgPositionIdNameList().stream().map(item -> BeanUtil.toBean(item, BffOrgPositionIdNameDto.class)).collect(Collectors.toList()));//sourceId:63342_1
        }


        retData.setPageNum(queryPositionTitleListRespDto.getPageNum());
        retData.setPageSize(queryPositionTitleListRespDto.getPageSize());
        retData.setTotal(queryPositionTitleListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryPositionTitleListRespDto.getTotalNum()) / Double.valueOf(queryPositionTitleListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B1-3查询职务名称详情(管理）[1328]
     * gen by moon at 8/10/2022, 3:34:29 AM
     */
    @Trace(operationName = "B1-3查询职务名称详情(管理）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryPositionTitleDetailRespDto queryPositionTitleDetail(BffQueryPositionTitleDetailReqDto reqDto) {


        QueryPositionTitleDetailRespDto queryPositionTitleDetailRespDto_1 = null;
//步骤0: D1-3查询职务名称详情 - queryPositionTitleDetail
        QueryPositionTitleDetailRespDto queryPositionTitleDetailRespDto = null;
        QueryPositionTitleDetailReqDto queryPositionTitleDetailReqDto = new QueryPositionTitleDetailReqDto();
        if (reqDto != null) {
            queryPositionTitleDetailReqDto.setPositionIdNameId(reqDto.getPositionIdNameId());//sourceId:39430_1
        }

        /*D1-3查询职务名称详情[1490]   */
        Assert.isNull(queryPositionTitleDetailReqDto.getPositionIdNameId(), "B1-3查询职务名称详情(管理）-D1-3查询职务名称详情-职务名称ID不能为空", false);
        queryPositionTitleDetailRespDto = fwBasePositionClient.queryPositionTitleDetail(queryPositionTitleDetailReqDto).getData();

        queryPositionTitleDetailRespDto_1 = queryPositionTitleDetailRespDto;

        BffQueryPositionTitleDetailRespDto retData = new BffQueryPositionTitleDetailRespDto();
        if (queryPositionTitleDetailRespDto_1 != null) {
            retData.setPositionIdNameId(queryPositionTitleDetailRespDto_1.getPositionIdNameId());//sourceId:39532_1
            retData.setPositionIdName(queryPositionTitleDetailRespDto_1.getPositionIdName());//sourceId:39533_1
            retData.setSubjectLifeCycle(queryPositionTitleDetailRespDto_1.getSubjectLifeCycle());//sourceId:49644_1
            retData.setOperationInductionId(queryPositionTitleDetailRespDto_1.getOperationInductionId());//sourceId:39535_1
            retData.setOperateTime(queryPositionTitleDetailRespDto_1.getOperateTime());//sourceId:39540_1
            retData.setUserId(queryPositionTitleDetailRespDto_1.getUserId());//sourceId:49645_1
            retData.setUserFace(queryPositionTitleDetailRespDto_1.getUserFace());//sourceId:39537_1
            retData.setOperationName(queryPositionTitleDetailRespDto_1.getIdCardName());//sourceId:39538_1
            retData.setOperationNickName(queryPositionTitleDetailRespDto_1.getNickName());//sourceId:39539_1
        }


        return retData;
    }

    /**
     * B1-3查询职务名称列表(管理）[1327]
     * gen by moon at 8/10/2022, 3:34:26 AM
     */
    @Trace(operationName = "B1-3查询职务名称列表(管理）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryPositionTitleListRespDto queryPositionTitleList(BffQueryPositionTitleListReqDto reqDto) {


        QueryPositionTitleListRespDto queryPositionTitleListRespDto_1 = null;
//步骤0: D1-3查询职务名称列表 - queryPositionTitleList
        QueryPositionTitleListRespDto queryPositionTitleListRespDto = null;
        QueryPositionTitleListReqDto queryPositionTitleListReqDto = new QueryPositionTitleListReqDto();
        if (reqDto != null) {
            queryPositionTitleListReqDto.setIsArchive(reqDto.getIsArchive());//sourceId:49583_1
        }

        /*D1-3查询职务名称列表[1414]   */
        Assert.isNull(queryPositionTitleListReqDto.getIsArchive(), "B1-3查询职务名称列表(管理）-D1-3查询职务名称列表-是否存档不能为空", false);
        queryPositionTitleListRespDto = fwBasePositionClient.queryPositionTitleList(queryPositionTitleListReqDto).getData();

        queryPositionTitleListRespDto_1 = queryPositionTitleListRespDto;

        BffQueryPositionTitleListRespDto retData = new BffQueryPositionTitleListRespDto();
        if (queryPositionTitleListRespDto_1 != null) {
            retData.setOrgPositionIdNameList(queryPositionTitleListRespDto_1.getOrgPositionIdNameList().stream().map(item -> BeanUtil.toBean(item, BffOrgPositionIdNameDto.class)).collect(Collectors.toList()));//sourceId:39590_1
        }


        retData.setPageNum(queryPositionTitleListRespDto.getPageNum());
        retData.setPageSize(queryPositionTitleListRespDto.getPageSize());
        retData.setTotal(queryPositionTitleListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryPositionTitleListRespDto.getTotalNum()) / Double.valueOf(queryPositionTitleListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B1-3查询可存档职务名称条件(管理）[1326]
     * gen by moon at 8/10/2022, 3:34:24 AM
     */
    @Trace(operationName = "B1-3查询可存档职务名称条件(管理）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryArchivePositionTitleRespDto queryArchivePositionTitle(BffQueryArchivePositionTitleReqDto reqDto) {


        QueryPositionListRespDto queryPositionListRespDto_1 = null;
//步骤0: D1-3查询职务列表 - queryPositionList
        QueryPositionListRespDto queryPositionListRespDto = null;
        QueryPositionListReqDto queryPositionListReqDto = new QueryPositionListReqDto();
        queryPositionListReqDto.setSubjectLifeCycle("EDITING");//sourceId:53916_1
        if (reqDto != null) {
            queryPositionListReqDto.setPositionIdNameId(reqDto.getPositionIdNameId());//sourceId:53911_1
        }

        /*D1-3查询职务列表[790]   */
        Assert.isNull(queryPositionListReqDto.getPositionIdNameId(), "B1-3查询可存档职务名称条件(管理）-D1-3查询职务列表-关联职务名称ID不能为空", false);
        Assert.isNull(queryPositionListReqDto.getSubjectLifeCycle(), "B1-3查询可存档职务名称条件(管理）-D1-3查询职务列表-主体生命周期不能为空", false);
        queryPositionListRespDto = fwBasePositionClient.queryPositionList(queryPositionListReqDto).getData();

        queryPositionListRespDto_1 = queryPositionListRespDto;

        BffQueryArchivePositionTitleRespDto retData = new BffQueryArchivePositionTitleRespDto();
        if (queryPositionListRespDto_1 != null) {
            retData.setOrgPositionList(queryPositionListRespDto_1.getOrgPositionList().stream().map(item -> item.getPositionId())
                    .collect(Collectors.toList()));//sourceId:53918_1
        }


        return retData;
    }

    /**
     * B1-3修改职务名称(管理）[1325]
     * gen by moon at 8/10/2022, 3:34:23 AM
     */
    @Trace(operationName = "B1-3修改职务名称(管理）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffUpdatePositionTitleRespDto updatePositionTitle(BffUpdatePositionTitleReqDto reqDto) {


        //步骤0: D1-3修改职务名称 - updatePositionTitle
        UpdatePositionTitleRespDto updatePositionTitleRespDto = null;
        UpdatePositionTitleReqDto updatePositionTitleReqDto = new UpdatePositionTitleReqDto();
        if (reqDto != null) {
            updatePositionTitleReqDto.setPositionIdNameId(reqDto.getPositionIdNameId());//sourceId:39360_1
            updatePositionTitleReqDto.setPositionIdName(reqDto.getPositionIdName());//sourceId:39361_1
            updatePositionTitleReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:49570_1
        }

        /*D1-3修改职务名称[1488]   */
        Assert.isNull(updatePositionTitleReqDto.getPositionIdNameId(), "B1-3修改职务名称(管理）-D1-3修改职务名称-职务名称ID不能为空", false);
        updatePositionTitleRespDto = fwBasePositionClient.updatePositionTitle(updatePositionTitleReqDto).getData();


        BffUpdatePositionTitleRespDto retData = new BffUpdatePositionTitleRespDto();


        return retData;
    }

    /**
     * B1-3新增职务名称(管理）[1324]
     * gen by moon at 8/10/2022, 3:34:21 AM
     */
    @Trace(operationName = "B1-3新增职务名称(管理）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddPositionTitleRespDto addPositionTitle(BffAddPositionTitleReqDto reqDto) {


        AddPositionTitleRespDto addPositionTitleRespDto_1 = null;
//步骤0: D1-3新增职务名称 - addPositionTitle
        AddPositionTitleRespDto addPositionTitleRespDto = null;
        AddPositionTitleReqDto addPositionTitleReqDto = new AddPositionTitleReqDto();
        if (reqDto != null) {
            addPositionTitleReqDto.setPositionIdName(reqDto.getPositionIdName());//sourceId:39247_1
            addPositionTitleReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:49577_1
        }

        /*D1-3新增职务名称[1485]   */
        Assert.isNull(addPositionTitleReqDto.getPositionIdName(), "B1-3新增职务名称(管理）-D1-3新增职务名称-职务名称不能为空", false);
        Assert.isNull(addPositionTitleReqDto.getSubjectLifeCycle(), "B1-3新增职务名称(管理）-D1-3新增职务名称-主体生命周期不能为空", false);
        addPositionTitleRespDto = fwBasePositionClient.addPositionTitle(addPositionTitleReqDto).getData();

        addPositionTitleRespDto_1 = addPositionTitleRespDto;

        BffAddPositionTitleRespDto retData = new BffAddPositionTitleRespDto();
        if (addPositionTitleRespDto_1 != null) {
            retData.setPositionIdNameId(addPositionTitleRespDto_1.getPositionIdNameId());//sourceId:39366_1
        }


        return retData;
    }

    /**
     * B1-3存档职务（管理）[905]
     */
    @Trace(operationName = "B1-3存档职务（管理）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffArchivePositionRespDto archivePosition(BffArchivePositionReqDto reqDto) {


        //步骤0: D1-3存档职务 - archivePosition
        ArchivePositionRespDto archivePositionRespDto = null;
        ArchivePositionReqDto archivePositionReqDto = new ArchivePositionReqDto();
        if (reqDto != null) {
            archivePositionReqDto.setPositionId(reqDto.getPositionId());//sourceId:17492_1
        }

        /*D1-3存档职务[904]   */
        archivePositionRespDto = fwBasePositionClient.archivePosition(archivePositionReqDto).getData();


        BffArchivePositionRespDto retData = new BffArchivePositionRespDto();


        return retData;
    }

    /**
     * B1-3-修改职务[878]
     * gen by moon at 8/10/2022, 3:31:06 AM
     */
    @Trace(operationName = "B1-3-修改职务")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffUpdatePositionRespDto updatePosition(BffUpdatePositionReqDto reqDto) {


        //步骤0: D1-3-修改职务 - updatePosition
        UpdatePositionRespDto updatePositionRespDto = null;
        UpdatePositionReqDto updatePositionReqDto = new UpdatePositionReqDto();
        if (reqDto != null) {
            updatePositionReqDto.setPositionId(reqDto.getPositionId());//sourceId:16776_1
            updatePositionReqDto.setPositionIdName(reqDto.getPositionIdName());//sourceId:16777_1
            updatePositionReqDto.setPositionIdNameId(reqDto.getPositionIdNameId());//sourceId:16778_1
            updatePositionReqDto.setPositionNumber(reqDto.getPositionNumber());//sourceId:16785_1
            updatePositionReqDto.setPositionType(reqDto.getPositionType());//sourceId:16779_1
            updatePositionReqDto.setPositionGradeId(reqDto.getPositionGradeId());//sourceId:16781_1
            updatePositionReqDto.setStationId(reqDto.getStationId());//sourceId:16782_1
            updatePositionReqDto.setTypeDictionaryId(reqDto.getTypeDictionaryId());//sourceId:16783_1
            updatePositionReqDto.setPositionDutyDesc(reqDto.getPositionDutyDesc());//sourceId:16786_1
            updatePositionReqDto.setPositionTargetDesc(reqDto.getPositionTargetDesc());//sourceId:16787_1
            updatePositionReqDto.setIsOrgPosition(reqDto.getIsOrgPosition());//sourceId:16788_1
            updatePositionReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:47452_1
        }

        /*D1-3-修改职务[838]   */
        Assert.isNull(updatePositionReqDto.getPositionId(), "B1-3-修改职务-D1-3-修改职务-职务ID不能为空", false);
        updatePositionRespDto = fwBasePositionClient.updatePosition(updatePositionReqDto).getData();


        BffUpdatePositionRespDto retData = new BffUpdatePositionRespDto();


        return retData;
    }

    /**
     * B1-3-新增职务（管理）[808]
     * gen by moon at 9/27/2022, 9:36:47 AM
     */
    @Trace(operationName = "B1-3-新增职务（管理）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffAddPositionRespDto addPosition(BffAddPositionReqDto reqDto) {


        AddPositionRespDto addPositionRespDto_1 = null;
//步骤0: D1-3-新增职务 - addPosition
        AddPositionRespDto addPositionRespDto = null;
        AddPositionReqDto addPositionReqDto = new AddPositionReqDto();
        if (reqDto != null) {
            addPositionReqDto.setPositionIdName(reqDto.getPositionIdName());//sourceId:16476_1
            addPositionReqDto.setPositionIdNameId(reqDto.getPositionIdNameId());//sourceId:16477_1
            addPositionReqDto.setPositionType(reqDto.getPositionType());//sourceId:16478_1
            addPositionReqDto.setPositionGradeId(reqDto.getPositionGradeId());//sourceId:16480_1
            addPositionReqDto.setStationId(reqDto.getStationId());//sourceId:16481_1
            addPositionReqDto.setTypeDictionaryId(reqDto.getTypeDictionaryId());//sourceId:16482_1
            addPositionReqDto.setPositionDutyDesc(reqDto.getPositionDutyDesc());//sourceId:16484_1
            addPositionReqDto.setPositionTargetDesc(reqDto.getPositionTargetDesc());//sourceId:16485_1
            addPositionReqDto.setPositionNumber(reqDto.getPositionNumber());//sourceId:16487_1
            addPositionReqDto.setOrgEntityId(reqDto.getOrgEntityId());//sourceId:351588_1
            addPositionReqDto.setIsOrgPosition(reqDto.getIsOrgPosition());//sourceId:47430_1
            addPositionReqDto.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:47431_1
        }

        /*D1-3-新增职务[806]   */
        Assert.isNull(addPositionReqDto.getPositionIdName(), "B1-3-新增职务（管理）-D1-3-新增职务-冗余职务名称不能为空", false);
        Assert.isNull(addPositionReqDto.getPositionIdNameId(), "B1-3-新增职务（管理）-D1-3-新增职务-关联职务名称ID不能为空", false);
        Assert.isNull(addPositionReqDto.getPositionType(), "B1-3-新增职务（管理）-D1-3-新增职务- 职务性质不能为空", false);
        Assert.isNull(addPositionReqDto.getPositionNumber(), "B1-3-新增职务（管理）-D1-3-新增职务-职务编号不能为空", false);
        Assert.isNull(addPositionReqDto.getOrgEntityId(), "B1-3-新增职务（管理）-D1-3-新增职务-所属对象实例ID不能为空", false);
        Assert.isNull(addPositionReqDto.getIsOrgPosition(), "B1-3-新增职务（管理）-D1-3-新增职务-是否可用于分管领导职务不能为空", false);
        Assert.isNull(addPositionReqDto.getSubjectLifeCycle(), "B1-3-新增职务（管理）-D1-3-新增职务-主体生命周期不能为空", false);
        addPositionRespDto = fwBasePositionClient.addPosition(addPositionReqDto).getData();


        addPositionRespDto_1 = addPositionRespDto;

        BffAddPositionRespDto retData = new BffAddPositionRespDto();
        if (addPositionRespDto_1 != null) {
            retData.setPositionId(addPositionRespDto_1.getPositionId());//sourceId:35847_1
            retData.setOrgPositionRelationshipId(addPositionRespDto_1.getOrgPositionRelationshipId());//sourceId:35848_1
            retData.setStaffingAccountId(addPositionRespDto_1.getStaffingAccountId());//sourceId:35849_1
        }


        return retData;
    }

    /**
     * B1-3查询职务列表（管理）[789]
     * gen by moon at 8/10/2022, 3:30:33 AM
     */
    @Trace(operationName = "B1-3查询职务列表（管理）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryPositionListRespDto queryPositionList(BffQueryPositionListReqDto reqDto) {


        QueryPositionListRespDto queryPositionListRespDto_1 = null;
//步骤0: D1-3查询职务列表 - queryPositionList
        QueryPositionListRespDto queryPositionListRespDto = null;
        QueryPositionListReqDto queryPositionListReqDto = new QueryPositionListReqDto();
        if (reqDto != null) {
            queryPositionListReqDto.setPositionIdName(reqDto.getPositionIdName());//sourceId:16679_1
            queryPositionListReqDto.setPositionGradeId(reqDto.getPositionGradeId());//sourceId:21799_1
            queryPositionListReqDto.setIsArchive(reqDto.getIsArchive());//sourceId:48489_1
        }

        /*查询职务列表[790]   */

        queryPositionListRespDto = fwBasePositionClient.queryPositionList(queryPositionListReqDto).getData();

        queryPositionListRespDto_1 = queryPositionListRespDto;

        BffQueryPositionListRespDto retData = new BffQueryPositionListRespDto();
        if (queryPositionListRespDto_1 != null) {
            retData.setOrgPositionList(queryPositionListRespDto_1.getOrgPositionList().stream().map(item -> BeanUtil.toBean(item, BffOrgPositionDto.class)).collect(Collectors.toList()));//sourceId:16716_1
        }


        retData.setPageNum(queryPositionListRespDto.getPageNum());
        retData.setPageSize(queryPositionListRespDto.getPageSize());
        retData.setTotal(queryPositionListRespDto.getTotalNum());
        retData.setIsLastPage((Math.ceil(Double.valueOf(queryPositionListRespDto.getTotalNum()) / Double.valueOf(queryPositionListRespDto.getPageSize()))) <= retData.getPageNum());


        return retData;
    }

    /**
     * B1-3批量更新职务（管理）[1442]
     * gen by moon at 8/10/2022, 3:35:30 AM
     */
    @Trace(operationName = "B1-3批量更新职务（管理）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffBatchUpdatePositionRespDto batchUpdatePosition(BffBatchUpdatePositionReqDto reqDto) {


        BffBatchUpdatePositionRespDto retData = new BffBatchUpdatePositionRespDto();


        return retData;
    }

    /**
     * B1-3查询管理模式职务详情(管理)[898]
     * gen by moon at 8/20/2022, 5:59:38 PM
     */
    @Trace(operationName = "B1-3查询管理模式职务详情(管理)")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Override
    public BffQueryPositionMgtDetailRespDto queryPositionMgtDetail(BffQueryPositionMgtDetailReqDto reqDto) {


        QueryPositionDetailRespDto queryPositionDetailRespDto_1 = null;
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto_1 = null;
//步骤0: D1-3查询职务详情 - queryPositionDetail
        QueryPositionDetailRespDto queryPositionDetailRespDto = null;
        QueryPositionDetailReqDto queryPositionDetailReqDto = new QueryPositionDetailReqDto();
        if (reqDto != null) {
            queryPositionDetailReqDto.setPositionId(reqDto.getPositionId());//sourceId:48182_1
        }

        /*D1-3查询职务详情[930]   */
        Assert.isNull(queryPositionDetailReqDto.getPositionId(), "B1-3查询管理模式职务详情(管理)-D1-3查询职务详情-职务ID不能为空", false);
        queryPositionDetailRespDto = fwBasePositionClient.queryPositionDetail(queryPositionDetailReqDto).getData();

        queryPositionDetailRespDto_1 = queryPositionDetailRespDto;

//步骤1: D1-3查询个人就职记录信息详情（公共） - queryInductionRecordInfoDetailCom
        QueryInductionRecordInfoDetailComRespDto queryInductionRecordInfoDetailComRespDto = null;
        if (queryPositionDetailRespDto != null) {
            QueryInductionRecordInfoDetailComReqDto queryInductionRecordInfoDetailComReqDto = new QueryInductionRecordInfoDetailComReqDto();
            if (queryPositionDetailRespDto != null) {
                queryInductionRecordInfoDetailComReqDto.setInductionRecordId(queryPositionDetailRespDto.getOperationInductionId());//sourceId:18751_1
            }

            /*D1-3查询个人就职记录信息详情（公共）[715]   */
            Assert.isNull(queryInductionRecordInfoDetailComReqDto.getInductionRecordId(), "B1-3查询管理模式职务详情(管理)-D1-3查询个人就职记录信息详情（公共）-就职记录ID不能为空", false);
            queryInductionRecordInfoDetailComRespDto = fwBaseInductionRecordClient.queryInductionRecordInfoDetailCom(queryInductionRecordInfoDetailComReqDto).getData();

            queryInductionRecordInfoDetailComRespDto_1 = queryInductionRecordInfoDetailComRespDto;
        }

        BffQueryPositionMgtDetailRespDto retData = new BffQueryPositionMgtDetailRespDto();
        if (queryPositionDetailRespDto_1 != null) {
            retData.setPositionId(queryPositionDetailRespDto_1.getPositionId());//sourceId:48206_1
            retData.setPositionIdName(queryPositionDetailRespDto_1.getPositionIdName());//sourceId:48208_1
            retData.setPositionType(queryPositionDetailRespDto_1.getPositionType());//sourceId:48210_1
            retData.setPositionNumber(queryPositionDetailRespDto_1.getPositionNumber());//sourceId:48212_1
            retData.setPositionIdNameId(queryPositionDetailRespDto_1.getPositionIdNameId());//sourceId:48214_1
            retData.setPositionGradeId(queryPositionDetailRespDto_1.getPositionGradeId());//sourceId:200919_1
            retData.setPositionGradeName(queryPositionDetailRespDto_1.getPositionGradeName());//sourceId:48216_1
            retData.setStationId(queryPositionDetailRespDto_1.getStationId());//sourceId:200920_1
            retData.setStationName(queryPositionDetailRespDto_1.getStationName());//sourceId:48218_1
            retData.setPostId(queryPositionDetailRespDto_1.getPostId());//sourceId:200921_1
            retData.setPostName(queryPositionDetailRespDto_1.getPostName());//sourceId:48220_1
            retData.setTypeDictionaryId(queryPositionDetailRespDto_1.getTypeDictionaryId());//sourceId:200922_1
            retData.setPositionClassName(queryPositionDetailRespDto_1.getTypeDictionaryName());//sourceId:48222_1
            retData.setStationTypeId(queryPositionDetailRespDto_1.getStationTypeId());//sourceId:200923_1
            retData.setStationTypeName(queryPositionDetailRespDto_1.getStationTypeName());//sourceId:48223_1
            retData.setIsOrgPosition(queryPositionDetailRespDto_1.getIsOrgPosition());//sourceId:48226_1
            retData.setPositionDutyDesc(queryPositionDetailRespDto_1.getPositionDutyDesc());//sourceId:200924_1
            retData.setPositionTargetDesc(queryPositionDetailRespDto_1.getPositionTargetDesc());//sourceId:200925_1
            retData.setSubjectLifeCycle(queryPositionDetailRespDto_1.getSubjectLifeCycle());//sourceId:48227_1
            retData.setOperationInductionId(queryPositionDetailRespDto_1.getOperationInductionId());//sourceId:48228_1
            retData.setOperateTime(queryPositionDetailRespDto_1.getOperateTime());//sourceId:48229_1
            retData.setOrgGradeScopeList(queryPositionDetailRespDto_1.getOrgGradeScopeList().stream().map(item -> BeanUtil.toBean(item, BffOrgGradeScopeDto.class)).collect(Collectors.toList()));//sourceId:51029_1
        }
        if (queryInductionRecordInfoDetailComRespDto_1 != null) {
            retData.setUserId(queryInductionRecordInfoDetailComRespDto_1.getUserId());//sourceId:48230_1
            retData.setUserFace(queryInductionRecordInfoDetailComRespDto_1.getUserFace());//sourceId:48231_1
            retData.setOperateName(queryInductionRecordInfoDetailComRespDto_1.getIdCardName());//sourceId:48232_1
            retData.setNickName(queryInductionRecordInfoDetailComRespDto_1.getNickName());//sourceId:48233_1
        }


        return retData;
    }
    //
}
